#
# Makefile, Makefile.in
# Makefiles for the Interface components of the Protea Project
# Copyright (C) 2008 Bruce A. James
#
# This file is part of the Protea Project.
#
# The Protea Project is free software; you can redistribute it and/or modify it 
# under the terms of the GNU General Public License as published by the 
# Free Software Foundation, either version 3 of the License, or (at your 
# option) any later version.
#
# The Protea Project is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
# for more details.
# 
# You should have received a copy of the GNU General Public License along 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Please send correspondence to:
#
# theproteaproject@gmail.com
#

PROGRAMS = xmlint fileint

CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ @INTERNAL_FLAG@  -I$(XERCESCROOT)/include
COMPILE = $(CXX) $(CXXFLAGS)

LIBS = @LIBS@ -L.. -lprotea$(TOOLSBASE)
XML=-L $(XERCESCROOT)/lib/ -lxerces-c -L $(XALANCROOT)/lib/ -lxalan-c -lxalanMsg
INSTALL = /@INSTALL@

SRCS := $(wildcard *.cpp)
DEPS := $(patsubst %.cpp,%.d,$(SRCS))
OBJS := $(patsubst %.cpp,%.o,$(SRCS))
SDK := ../SDK/SDKDate

all : $(PROGRAMS)

install:
	@echo "Installing user interface components"

	@$(INSTALL) -d $(XSIROOT)/Tools

	@$(INSTALL) $(PROGRAMS) $(XSIROOT)/Tools

xmlint: xmlint.o xmlparse.o xmlapp.o comm_standard.o
	@echo "Linking xmlint program"
	@set -e; $(COMPILE) -o $@ $(XML) $(LIBS) $^

fileint: fileint.o
	@echo "Linking fileint program"
	@set -e; $(COMPILE) -o $@ $(XML) $(LIBS) $<

%.o: %.cpp
	@echo "Compiling source file: $*.cpp"
	@set -e; $(COMPILE) -c -ggdb -o $@ $<

%.d: %.cpp
	@echo "Creating dependency file: $*.d"
	@set -e; g++ -MM -I$(XERCESCROOT)/include $< \
	| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
	[ -s $@ ] || rm -f $@

clean :
	-rm $(PROGRAMS) $(DEPS) $(OBJS)

-include $(DEPS)
